package com.lagou.rocket.demo.controller;

import com.lagou.rocket.demo.po.Course;
import com.lagou.rocket.demo.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class CourseController {

    @Autowired
    private CourseService courseService;

    @RequestMapping("/list/crs")
    public String listCourses(Model model) {

        final List<Course> courses = courseService.listCourses();

        model.addAttribute("courseList", courses);
        return "list";
    }

}
